//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS WorkMailMessageFlow service.
///
/// The WorkMail Message Flow API provides access to email messages as they are being sent and received by a WorkMail organization.
public struct WorkMailMessageFlow: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the WorkMailMessageFlow client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "WorkMailMessageFlow",
            serviceIdentifier: "workmailmessageflow",
            serviceProtocol: .restjson,
            apiVersion: "2019-05-01",
            endpoint: endpoint,
            errorType: WorkMailMessageFlowErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Retrieves the raw content of an in-transit email message, in MIME format.
    @Sendable
    @inlinable
    public func getRawMessageContent(_ input: GetRawMessageContentRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetRawMessageContentResponse {
        try await self.client.execute(
            operation: "GetRawMessageContent", 
            path: "/messages/{messageId}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves the raw content of an in-transit email message, in MIME format.
    ///
    /// Parameters:
    ///   - messageId: The identifier of the email message to retrieve.
    ///   - logger: Logger use during operation
    @inlinable
    public func getRawMessageContent(
        messageId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetRawMessageContentResponse {
        let input = GetRawMessageContentRequest(
            messageId: messageId
        )
        return try await self.getRawMessageContent(input, logger: logger)
    }

    /// Updates the raw content of an in-transit email message, in MIME format. This example describes how to update in-transit email message. For more information and examples for using this API, see   Updating message content with AWS Lambda.  Updates to an in-transit message only appear when you call PutRawMessageContent from an AWS Lambda function  configured with a  synchronous  Run Lambda rule. If you call PutRawMessageContent on a delivered or sent message, the message remains unchanged, even though GetRawMessageContent returns an updated  message.
    @Sendable
    @inlinable
    public func putRawMessageContent(_ input: PutRawMessageContentRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> PutRawMessageContentResponse {
        try await self.client.execute(
            operation: "PutRawMessageContent", 
            path: "/messages/{messageId}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Updates the raw content of an in-transit email message, in MIME format. This example describes how to update in-transit email message. For more information and examples for using this API, see   Updating message content with AWS Lambda.  Updates to an in-transit message only appear when you call PutRawMessageContent from an AWS Lambda function  configured with a  synchronous  Run Lambda rule. If you call PutRawMessageContent on a delivered or sent message, the message remains unchanged, even though GetRawMessageContent returns an updated  message.
    ///
    /// Parameters:
    ///   - content: Describes the raw message content of the updated email message.
    ///   - messageId: The identifier of the email message being updated.
    ///   - logger: Logger use during operation
    @inlinable
    public func putRawMessageContent(
        content: RawMessageContent,
        messageId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> PutRawMessageContentResponse {
        let input = PutRawMessageContentRequest(
            content: content, 
            messageId: messageId
        )
        return try await self.putRawMessageContent(input, logger: logger)
    }
}

extension WorkMailMessageFlow {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: WorkMailMessageFlow, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
